//Nicccce
import React, {Component} from 'react';
import NavigationBar from '../../Common/NavigationBar/NavigationBar.jsx';
import {CSS} from '../styles/zoneList.css';
import WeUI from 'react-weui';
const {
    Toptips,
} = WeUI;

export default class ZoneDetailsContainer extends Component {
    constructor(props) {
        super(props);
        this.state = {
            incubatorId: this.props.location.query.incubatorId,
            data: "",
            showWarn: false,
            warnTimer: null,
            tipText: "",
        }
    }

    showWarn(text) {
        this.setState({showWarn: true, tipText: text});
        this.state.warnTimer = setTimeout(() => {
            this.setState({showWarn: false});
        }, 2000);
    }

    componentWillMount() {
        let self = this;
        fetch(getHost() + "/incubator/display/edit/?incubatorId=" + this.state.incubatorId, {
            credentials: 'include'
        }).then(response => response.json())
            .then(d => {
                console.log(d);
                let intro = d.data;
                if (intro) {
                    self.setState({data: intro.introduction})
                } else {
                    self.showWarn("网络出了点问题，请重试！");
                }
            }).catch(e => {
            self.showWarn("网络不给力，请重试！");
        });
    }

    render() {
        let introduction = <div style={{textAlign: "center"}}>暂无信息</div>;
        if (this.state.data) {
            introduction = <div dangerouslySetInnerHTML={{__html: this.state.data}}/>
        }
        return (
            <div className="whiteBg">
                <NavigationBar Title="园区详情" LeftBar="true" LeftTitle="返回"
                               LeftIconSrc="/iot-meeting/assets/images/common/nav_back_icon.png" LeftClick={this.LeftClick}/>
                {introduction}
                <Toptips type="warn" show={this.state.showWarn}>{this.state.tipText}</Toptips>
            </div>
        )
    }


}
